<template>
  <v-container>
    <v-breadcrumbs :items="routerList">
      <template v-slot:item="{ item }">
        <v-breadcrumbs-item
          exact=true
          :to="item.path"
        >
            {{ item.meta.name }}
        </v-breadcrumbs-item>
      </template>
    </v-breadcrumbs>
  </v-container>
</template>

<script>
export default {
  data () {
    return {
      routerList: []
    }
  },
  created () {
    this.getBreadcrumb()
  },
  watch: {
    $route () {
      this.getBreadcrumb()
    }
  },
  methods: {
    getBreadcrumb () {
      let matched = this.$route.matched.filter(item => item.meta && item.meta.name)
      if (matched) {
        matched = [{ path: '/', meta: { name: '首页' } }].concat(matched)
      }
      console.log(matched)
      this.routerList = matched
    }
  }

}
</script>
